package com.mollytask.base;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mollytask.R;
import com.mollytask.bean.DataCheckList;

import java.util.List;

/**
 * Created by freshxu on 2017/5/24.
 */

public class CheckAdapter extends BaseQuickAdapter<DataCheckList, BaseViewHolder> {

    //表明是查看还是审核，用来显示不同的字
    private boolean isCheck;


    public CheckAdapter(@LayoutRes int layoutResId, @Nullable List<DataCheckList> data, boolean isCheck) {
        super(layoutResId, data);
        this.isCheck = isCheck;
    }

    @Override
    protected void convert(BaseViewHolder helper, DataCheckList item) {
        if (isCheck) {
            helper.setText(R.id.check_btn, "审核");
        } else {
            helper.setText(R.id.check_btn, "查看");

        }
        helper.setText(R.id.check_name, item.getName());
        helper.setText(R.id.check_time, item.getData());
        if (item.getStatus().equals("0")) {
            helper.setTextColor(R.id.check_status_text, mContext.getResources().getColor(android.R.color.holo_red_light));
            helper.setText(R.id.check_status_text, "待审核");

        } else if (item.getStatus().equals("1")) {
            helper.setTextColor(R.id.check_status_text, mContext.getResources().getColor(R.color.status_yes));
            helper.setText(R.id.check_status_text, "已通过");

        } else if (item.getStatus().equals("2")) {
            helper.setTextColor(R.id.check_status_text, mContext.getResources().getColor(R.color.status_not));
            helper.setText(R.id.check_status_text, "未通过");


        }

        helper.addOnClickListener(R.id.check_btn);

    }
}
